import request from '@/utils/request'

// 获取信息
export function getInfo(lockId) {
  return request({
    url: `/device/lock/${lockId}`,
    method: 'get',
  })
}

export function syncLock(lockId) {
  return request({
    url: `/device/lock/sync-lock/${lockId}`,
    method: 'post',
  })
}

export function getList(data) {
  return request({
    url: '/device/lock/list',
    method: 'get',
    params: data
  })
}

export function getKeyList(lockId, params) {
  return request({
    url: `/device/lock/keys/${lockId}`,
    method: 'get',
    params
  })
}

export function getPwdList(lockId, params) {
  return request({
    url: `/device/lock/pwdList/${lockId}`,
    method: 'get',
    params
  })
}

export function getRecordList(lockId, params) {
  return request({
    url: `/device/lock/records/${lockId}`,
    method: 'get',
    params
  })
}

export function getFingerprintList(lockId, params) {
  return request({
    url: `/device/lock/fingerprints/${lockId}`,
    method: 'get',
    params
  })
}

// 添加
export function add(data) {
  return request({
    url: '/device/lock',
    method: 'post',
    data: data
  })
}

// 编辑
export function edit(data) {
  return request({
    url: '/device/lock',
    method: 'put',
    data: data
  })
}

export function getSelect(data) {
  return request({
    url: '/device/lock/select',
    method: 'get',
    params: data
  })
}

// 开锁
export function unlock(lockId) {
  return request({
    url: `/device/lock/unlock/${lockId}`,
    method: 'post'
  })
}

// 解绑门锁
export function unBind(lockId) {
  return request({
    url: `/device/lock/unbind/${lockId}`,
    method: 'post'
  })
}

// 发送钥匙
export function sendKey(data) {
  return request({
    url: '/device/lock/send-key',
    method: 'post',
    data: data
  })
}

// 添加密码
export function addPwd(data) {
  return request({
    url: '/device/lock/add-pwd',
    method: 'post',
    data: data
  })
}

export function getUnbindList() {
  return request({
    url: '/device/lock/unbind-list',
    method: 'get',
  })
}

// 绑定房间
export function bindRoom(data) {
  return request({
    url: '/device/lock/bind-room',
    method: 'put',
    data: data
  })
}

// 获取密码
export function getRandomPwd(lockId, data) {
  return request({
    url: `/device/lock/get-random-pwd/${lockId}`,
    method: 'post',
    params: data
  })
}
export default {
  getInfo,
  add,
  edit,
  getList,
  getKeyList,
  getPwdList,
  unlock,
  unBind,
  syncLock,
  sendKey,
  addPwd,
  bindRoom,
  getUnbindList,
  getRecordList,
  getFingerprintList,
  getSelect,
  getRandomPwd
}